/* 
 * File:   ROI.h
 * Author: Guilherme Monteiro
 *
 */

#ifndef ROI_H
#define	ROI_H

#include <cstdlib>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <exception>
#include <cerrno>

#include "ImageCutter.h"
#include "GenericAdapter.h"
#include "NullImageException.h"
#include "InvalidRectException.h"

using namespace std;

/**
 * Class that represents a roi,
 * i.e., the region of interest of
 * the image in question.
 * 
 * @author Guilherme Monteiro
 * 
 */
class ROI {
public:
    ROI(CvPoint leftUpper, CvPoint rightBottom, 
            string originalHighResolutionImagePath,
            string originalLowResolutionImagePath, 
            string lowResolutionImageCutPath,
            string highResolutionImageCutPath,
            string logImageIncompletePath,
            string modelPreviewIncompletePath,
            bool isRotated, int indexROI);
    ROI(const ROI& orig);
    virtual ~ROI();
    
    CvPoint getLeftUpper();
    CvPoint getRightBottom();
    
    IplImage* getImageROI();
    void setImageROI() throw (NullImageException);
    void setImageROI(IplImage* r);
    
    string getOriginalHighResolutionImagePath();
    string getOriginalLowResolutionImagePath();
    
    int getIndexROI();
    
    string getLowResolutionImageCutPath();
    string getHighResolutionImageCutPath();
    
    string getModelPreviewPath();
    
    string getLogImagePath();
    
    void releaseROI();
    
    Line getUpLineTable();
    Line getLeftLineTable();
    Line getRightLineTable();
    Line getDownLineTable();
private:
    CvPoint leftUpper;
    CvPoint rightBottom;
    IplImage* imageROI;
    
    int indexROI;
    
    string originalHighResolutionImagePath;
    string originalLowResolutionImagePath;
    
    string lowResolutionImageCutPath;
    string highResolutionImageCutPath;
    string modelPreviewPath;
    
    string logImagePath;
    
    void setRightBottom(CvPoint point) throw (NullImageException);
    void setLeftUpper(CvPoint point) throw (NullImageException);
    
    void setOriginalHighResolutionImagePath(string originalHighResolutionImagePath);
    void setOriginalLowResolutionImagePath(string originalLowResolutionImagePath);
    
    void setIndexROI(int index);
    
    void setHighResolutionImageCutPath(string highResolutionImageCutIncompletePath);
    void setLowResolutionImageCutPath(string lowResolutionImageCutIncompletePath);
    void setModelPreviewPath(string modelPreviewIncompletePath);
    void setLogImagePath(string logImageIncompletePath, bool isRotated);
};

#endif	/* ROI_H */

